/*
 * This file is part of the CXHWebImage package.
 * (c) Olivier Poitrey <rs@dailymotion.com>
 * (c) Fabrice Aneche
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

#import <Foundation/Foundation.h>
#import "CXHWebImageCompat.h"

/**
 You can use switch case like normal enum. It's also recommended to add a default case. You should not assume anything about the raw value.
 For custom coder plugin, it can also extern the enum for supported format. See `CXHImageCoder` for more detailed information.
 */
typedef NSInteger CXHImageFormat NS_TYPED_EXTENSIBLE_ENUM;
static const CXHImageFormat CXHImageFormatUndefined = -1;
static const CXHImageFormat CXHImageFormatJPEG      = 0;
static const CXHImageFormat CXHImageFormatPNG       = 1;
static const CXHImageFormat CXHImageFormatGIF       = 2;
static const CXHImageFormat CXHImageFormatTIFF      = 3;
static const CXHImageFormat CXHImageFormatWebP      = 4;
static const CXHImageFormat CXHImageFormatHEIC      = 5;
static const CXHImageFormat CXHImageFormatHEIF      = 6;
static const CXHImageFormat CXHImageFormatPDF       = 7;
static const CXHImageFormat CXHImageFormatSVG       = 8;
static const CXHImageFormat CXHImageFormatBMP       = 9;
static const CXHImageFormat CXHImageFormatRAW       = 10;

/**
 NSData category about the image content type and UTI.
 */
@interface NSData (CXHImageContentType)

/**
 *  Return image format
 *
 *  @param data the input image data
 *
 *  @return the image format as `CXHImageFormat` (enum)
 */
+ (CXHImageFormat)cxh_imageFormatForImageData:(nullable NSData *)data;

/**
 *  Convert CXHImageFormat to UTType
 *
 *  @param format Format as CXHImageFormat
 *  @return The UTType as CFStringRef
 *  @note For unknown format, `kCXHUTTypeGIFImage` abstract type will return
 */
+ (nonnull CFStringRef)cxh_UTTypeFromImageFormat:(CXHImageFormat)format CF_RETURNS_NOT_RETAINED NS_SWIFT_NAME(cxh_UTType(from:));

/**
 *  Convert UTType to CXHImageFormat
 *
 *  @param uttype The UTType as CFStringRef
 *  @return The Format as CXHImageFormat
 *  @note For unknown type, `CXHImageFormatUndefined` will return
 */
+ (CXHImageFormat)cxh_imageFormatFromUTType:(nonnull CFStringRef)uttype;

@end
